<!DOCTYPE html><html lang="zh-CN" data-theme="light"><head><meta charset="UTF-8"><meta http-equiv="X-UA-Compatible" content="IE=edge"><meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no"><title>Codeql 环境手模手搭建和简单使用 | Zeo's Security Lab</title><meta name="author" content="Zeo"><meta name="copyright" content="Zeo"><meta name="format-detection" content="telephone=no"><meta name="theme-color" content="ffffff"><meta name="description" content="0x00 前言  最近这个东西实在太火了，而且log4j 和最近的Spring Cloud Gateway 都说是利用codeql来挖掘的，好不好用先用了再说。所以学习一下这个东西   　  0x01 CodeQL是什么 　　在我接触这个东西之前，我一直以为这是一个代码审计的工具，类似于Fortify rips 这种东西？　但其实并不是，理解大大错了。。。 还记得记得SQL的全称吗？ -&amp;gt">
<meta property="og:type" content="article">
<meta property="og:title" content="Codeql 环境手模手搭建和简单使用">
<meta property="og:url" content="https://godzeo.github.io/2022/03/14/Codeql%20%E7%8E%AF%E5%A2%83%E6%89%8B%E6%A8%A1%E6%89%8B%E6%90%AD%E5%BB%BA%E5%92%8C%E7%AE%80%E5%8D%95%E4%BD%BF%E7%94%A8/index.html">
<meta property="og:site_name" content="Zeo&#39;s Security Lab">
<meta property="og:description" content="0x00 前言  最近这个东西实在太火了，而且log4j 和最近的Spring Cloud Gateway 都说是利用codeql来挖掘的，好不好用先用了再说。所以学习一下这个东西   　  0x01 CodeQL是什么 　　在我接触这个东西之前，我一直以为这是一个代码审计的工具，类似于Fortify rips 这种东西？　但其实并不是，理解大大错了。。。 还记得记得SQL的全称吗？ -&amp;gt">
<meta property="og:locale" content="zh_CN">
<meta property="og:image" content="https://image-1257110520.cos.ap-beijing.myqcloud.com/old/202210231225559.webp">
<meta property="article:published_time" content="2022-03-14T04:26:04.000Z">
<meta property="article:modified_time" content="2022-11-28T12:25:22.940Z">
<meta property="article:author" content="Zeo">
<meta property="article:tag" content="vscode web安全 代码审计 安全">
<meta name="twitter:card" content="summary">
<meta name="twitter:image" content="https://image-1257110520.cos.ap-beijing.myqcloud.com/old/202210231225559.webp"><link rel="shortcut icon" href="/img/WX20211124-162855.png"><link rel="canonical" href="https://godzeo.github.io/2022/03/14/Codeql%20%E7%8E%AF%E5%A2%83%E6%89%8B%E6%A8%A1%E6%89%8B%E6%90%AD%E5%BB%BA%E5%92%8C%E7%AE%80%E5%8D%95%E4%BD%BF%E7%94%A8/"><link rel="preconnect" href="//cdn.jsdelivr.net"/><link rel="stylesheet" href="/css/index.css"><link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/@fortawesome/fontawesome-free/css/all.min.css" media="print" onload="this.media='all'"><link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/@fancyapps/ui/dist/fancybox.min.css" media="print" onload="this.media='all'"><script>const GLOBAL_CONFIG = { 
  root: '/',
  algolia: undefined,
  localSearch: undefined,
  translate: undefined,
  noticeOutdate: undefined,
  highlight: {"plugin":"highlighjs","highlightCopy":true,"highlightLang":true,"highlightHeightLimit":false},
  copy: {
    success: '复制成功',
    error: '复制错误',
    noSupport: '浏览器不支持'
  },
  relativeDate: {
    homepage: false,
    post: false
  },
  runtime: '',
  date_suffix: {
    just: '刚刚',
    min: '分钟前',
    hour: '小时前',
    day: '天前',
    month: '个月前'
  },
  copyright: undefined,
  lightbox: 'fancybox',
  Snackbar: undefined,
  source: {
    justifiedGallery: {
      js: 'https://cdn.jsdelivr.net/npm/flickr-justified-gallery/dist/fjGallery.min.js',
      css: 'https://cdn.jsdelivr.net/npm/flickr-justified-gallery/dist/fjGallery.min.css'
    }
  },
  isPhotoFigcaption: false,
  islazyload: false,
  isAnchor: false
}</script><script id="config-diff">var GLOBAL_CONFIG_SITE = {
  title: 'Codeql 环境手模手搭建和简单使用',
  isPost: true,
  isHome: false,
  isHighlightShrink: false,
  isToc: true,
  postUpdate: '2022-11-28 20:25:22'
}</script><noscript><style type="text/css">
  #nav {
    opacity: 1
  }
  .justified-gallery img {
    opacity: 1
  }

  #recent-posts time,
  #post-meta time {
    display: inline !important
  }
</style></noscript><script>(win=>{
    win.saveToLocal = {
      set: function setWithExpiry(key, value, ttl) {
        if (ttl === 0) return
        const now = new Date()
        const expiryDay = ttl * 86400000
        const item = {
          value: value,
          expiry: now.getTime() + expiryDay,
        }
        localStorage.setItem(key, JSON.stringify(item))
      },

      get: function getWithExpiry(key) {
        const itemStr = localStorage.getItem(key)

        if (!itemStr) {
          return undefined
        }
        const item = JSON.parse(itemStr)
        const now = new Date()

        if (now.getTime() > item.expiry) {
          localStorage.removeItem(key)
          return undefined
        }
        return item.value
      }
    }
  
    win.getScript = url => new Promise((resolve, reject) => {
      const script = document.createElement('script')
      script.src = url
      script.async = true
      script.onerror = reject
      script.onload = script.onreadystatechange = function() {
        const loadState = this.readyState
        if (loadState && loadState !== 'loaded' && loadState !== 'complete') return
        script.onload = script.onreadystatechange = null
        resolve()
      }
      document.head.appendChild(script)
    })
  
      win.activateDarkMode = function () {
        document.documentElement.setAttribute('data-theme', 'dark')
        if (document.querySelector('meta[name="theme-color"]') !== null) {
          document.querySelector('meta[name="theme-color"]').setAttribute('content', '#0d0d0d')
        }
      }
      win.activateLightMode = function () {
        document.documentElement.setAttribute('data-theme', 'light')
        if (document.querySelector('meta[name="theme-color"]') !== null) {
          document.querySelector('meta[name="theme-color"]').setAttribute('content', 'ffffff')
        }
      }
      const t = saveToLocal.get('theme')
    
          if (t === 'dark') activateDarkMode()
          else if (t === 'light') activateLightMode()
        
      const asideStatus = saveToLocal.get('aside-status')
      if (asideStatus !== undefined) {
        if (asideStatus === 'hide') {
          document.documentElement.classList.add('hide-aside')
        } else {
          document.documentElement.classList.remove('hide-aside')
        }
      }
    
    const detectApple = () => {
      if(/iPad|iPhone|iPod|Macintosh/.test(navigator.userAgent)){
        document.documentElement.classList.add('apple')
      }
    }
    detectApple()
    })(window)</script><meta name="generator" content="Hexo 6.3.0"><link rel="alternate" href="/atom.xml" title="Zeo's Security Lab" type="application/atom+xml">
</head><body><div id="sidebar"><div id="menu-mask"></div><div id="sidebar-menus"><div class="avatar-img is-center"><img src="https://image-1257110520.cos.ap-beijing.myqcloud.com/old/202210231013354.png" onerror="onerror=null;src='/img/friend_404.gif'" alt="avatar"/></div><div class="sidebar-site-data site-data is-center"><a href="/archives/"><div class="headline">文章</div><div class="length-num">125</div></a><a href="/tags/"><div class="headline">标签</div><div class="length-num">46</div></a><a href="/categories/"><div class="headline">分类</div><div class="length-num">9</div></a></div><hr/><div class="menus_items"><div class="menus_item"><a class="site-page" href="/"><i class="fa-fw fas fa-home"></i><span> Home</span></a></div><div class="menus_item"><a class="site-page" href="/archives/"><i class="fa-fw fas fa-archive"></i><span> Archives</span></a></div><div class="menus_item"><a class="site-page" href="/categories/"><i class="fa-fw fas fa-folder-open"></i><span> Categories</span></a></div><div class="menus_item"><a class="site-page group" href="javascript:void(0);"><i class="fa-fw fas fa-list"></i><span> List</span><i class="fas fa-chevron-down"></i></a><ul class="menus_item_child"><li><a class="site-page child" href="/music/"><i class="fa-fw fas fa-music"></i><span> Music</span></a></li><li><a class="site-page child" href="/movies/"><i class="fa-fw fas fa-video"></i><span> Movie</span></a></li></ul></div><div class="menus_item"><a class="site-page" href="/about/"><i class="fa-fw fas fa-heart"></i><span> About</span></a></div></div></div></div><div class="post" id="body-wrap"><header class="post-bg" id="page-header" style="background-image: url('https://image-1257110520.cos.ap-beijing.myqcloud.com/old/202210231225559.webp')"><nav id="nav"><span id="blog_name"><a id="site-name" href="/">Zeo's Security Lab</a></span><div id="menus"><div class="menus_items"><div class="menus_item"><a class="site-page" href="/"><i class="fa-fw fas fa-home"></i><span> Home</span></a></div><div class="menus_item"><a class="site-page" href="/archives/"><i class="fa-fw fas fa-archive"></i><span> Archives</span></a></div><div class="menus_item"><a class="site-page" href="/categories/"><i class="fa-fw fas fa-folder-open"></i><span> Categories</span></a></div><div class="menus_item"><a class="site-page group" href="javascript:void(0);"><i class="fa-fw fas fa-list"></i><span> List</span><i class="fas fa-chevron-down"></i></a><ul class="menus_item_child"><li><a class="site-page child" href="/music/"><i class="fa-fw fas fa-music"></i><span> Music</span></a></li><li><a class="site-page child" href="/movies/"><i class="fa-fw fas fa-video"></i><span> Movie</span></a></li></ul></div><div class="menus_item"><a class="site-page" href="/about/"><i class="fa-fw fas fa-heart"></i><span> About</span></a></div></div><div id="toggle-menu"><a class="site-page"><i class="fas fa-bars fa-fw"></i></a></div></div></nav><div id="post-info"><h1 class="post-title">Codeql 环境手模手搭建和简单使用</h1><div id="post-meta"><div class="meta-firstline"><span class="post-meta-date"><i class="far fa-calendar-alt fa-fw post-meta-icon"></i><span class="post-meta-label">发表于</span><time class="post-meta-date-created" datetime="2022-03-14T04:26:04.000Z" title="发表于 2022-03-14 12:26:04">2022-03-14</time><span class="post-meta-separator">|</span><i class="fas fa-history fa-fw post-meta-icon"></i><span class="post-meta-label">更新于</span><time class="post-meta-date-updated" datetime="2022-11-28T12:25:22.940Z" title="更新于 2022-11-28 20:25:22">2022-11-28</time></span><span class="post-meta-categories"><span class="post-meta-separator">|</span><i class="fas fa-inbox fa-fw post-meta-icon"></i><a class="post-meta-categories" href="/categories/%E4%BB%A3%E7%A0%81%E5%AE%A1%E8%AE%A1/">代码审计</a></span></div><div class="meta-secondline"></div></div></div></header><main class="layout" id="content-inner"><div id="post"><article class="post-content" id="article-container"><span id="more"></span>

<h2 id="0x00-前言"><a href="#0x00-前言" class="headerlink" title="0x00 前言"></a>0x00 前言</h2><p> </p>
<p>最近这个东西实在太火了，而且log4j 和最近的<a target="_blank" rel="noopener" href="https://blog.csdn.net/god_zzZ/article/details/123314194">Spring Cloud Gateway</a> 都说是利用codeql来挖掘的，好不好用先用了再说。所以学习一下这个东西  
　 </p>
<h2 id="0x01-CodeQL是什么"><a href="#0x01-CodeQL是什么" class="headerlink" title="0x01 CodeQL是什么"></a>0x01 CodeQL是什么</h2><p> <br>　　<br>在我接触这个东西之前，我一直以为这是一个代码审计的工具，类似于Fortify rips 这种东西？<br>　<br>但其实并不是，理解大大错了。。。</p>
<p>还记得记得SQL的全称吗？ -&gt; Structured Query Language:结构化查询语言</p>
<p>所以我简单通俗的理解就是：</p>
<ul>
<li>Codeql &#x3D; code + ql，这样就是一门面向对象的编程语言（对比SQL）</li>
<li>是把代码结构化分析后的存在一个代码数据库里面</li>
<li>然后就是写ql就可以进行各种查询</li>
<li>找某个方法、类、参数的传递等等。。。</li>
</ul>
<p>神奇。。</p>
<p>官方地址：</p>
<p><a target="_blank" rel="noopener" href="https://github.com/github/codeql">github&#x2F;codeql: CodeQL: the libraries and queries that power security researchers around the world, as well as code scanning in GitHub Advanced Security (code scanning), LGTM.com, and LGTM Enterprise</a></p>
<p><a target="_blank" rel="noopener" href="https://github.com/github/codeql">https://github.com/github/codeql</a></p>
<p>   
 </p>
<h2 id="0x01-相关下载"><a href="#0x01-相关下载" class="headerlink" title="0x01 相关下载"></a>0x01 相关下载</h2><p> </p>
<p>CodeQL本身包含两部分解析引擎+SDK</p>
<p>我推荐直接下载这个！可以直接配合 vscode 的现成项目，使用方便。</p>
<p><a target="_blank" rel="noopener" href="https://github.com/github/vscode-codeql-starter">https://github.com/github/vscode-codeql-starter</a></p>
<p>（注意下载的时候不能直接git clon，因为里面包含子项目</p>
<p><img src="https://img-blog.csdnimg.cn/img_convert/6a3c5018d5d0d0db8e4f98dcdca28a2b.png" alt="image-20220304221924777"></p>
<p>        </p>
<h2 id="0x02-安装详细步骤"><a href="#0x02-安装详细步骤" class="headerlink" title="0x02 安装详细步骤"></a>0x02 安装详细步骤</h2><p>        </p>
<p>我这边推荐使用 vscode-codeql-starter 这个现成的项目，使用起来很方便</p>
<h3 id="1、vscode-环境"><a href="#1、vscode-环境" class="headerlink" title="1、vscode 环境"></a>1、vscode 环境</h3><ul>
<li>首先需要在官网下载并安装Visual Studio Code</li>
</ul>
<p><a target="_blank" rel="noopener" href="https://code.visualstudio.com/">Visual Studio Code - Code Editing. Redefined</a></p>
<ul>
<li>安装codeql插件：</li>
</ul>
<p><img src="https://img-blog.csdnimg.cn/img_convert/1e197eb521572e3f8c5127107423f3a2.png" alt="image-20220304222734040"></p>
<p>        </p>
<h3 id="2-安装-CodeQL-引擎"><a href="#2-安装-CodeQL-引擎" class="headerlink" title="2 安装 CodeQL 引擎"></a>2 安装 CodeQL 引擎</h3><p>        </p>
<p>s引擎二进制文件下载 ：<a target="_blank" rel="noopener" href="https://github.com/github/codeql-cli-binaries/releases">Releases · github&#x2F;codeql-cli-binaries</a></p>
<p>（推荐直接下载codeql.zip 这个是多平台都打包在一起）</p>
<p><img src="https://img-blog.csdnimg.cn/img_convert/a2cb467ec36e31755ce60c6ea7d6bbc8.png" alt="image-20220304221553522"></p>
<p>        </p>
<h3 id="3-克隆工作车间-Codeql-starter"><a href="#3-克隆工作车间-Codeql-starter" class="headerlink" title="3 克隆工作车间 Codeql starter"></a>3 克隆工作车间 Codeql starter</h3><p>        </p>
<p>我推荐直接下载这个！可以直接配合 vscode 的现成项目，使用方便。</p>
<p><a target="_blank" rel="noopener" href="https://github.com/github/vscode-codeql-starter">https://github.com/github/vscode-codeql-starter</a></p>
<p>（注意下载的时候不能直接git clone，因为里面包含子项目</p>
<p><img src="https://img-blog.csdnimg.cn/img_convert/6a3c5018d5d0d0db8e4f98dcdca28a2b.png" alt="image-20220304221924777"></p>
<p>这个项目里的 submodule 也须要 Clone</p>
<p>使用下面命令一步到位</p>
<figure class="highlight bash"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">git <span class="built_in">clone</span> --recursive https://github.com/github/vscode-codeql-starter/</span><br></pre></td></tr></table></figure>

<p><img src="https://img-blog.csdnimg.cn/img_convert/6592caf3f2edce99827af28ea26d87c7.png" alt="image-20220304224556711"><br>(如果子模块clone失败，可以自己下载放进去也行)</p>
<p>        </p>
<h3 id="4-配置环境变量"><a href="#4-配置环境变量" class="headerlink" title="4 配置环境变量"></a>4 配置环境变量</h3><p> </p>
<p>1 、在 VSCode 菜单中点击 <code>File &gt; Open Workspace</code> 选择 <code>vscode-codeql-starter.code-workspace</code> 这个文件来打开这个工作区。</p>
<p>2、找到插件的扩展设置</p>
<p><img src="https://img-blog.csdnimg.cn/img_convert/426fefbba4e3f578100b4c814db923e3.png" alt="image-20220304225202804"></p>
<p>3、设置引擎地址</p>
<p>这里面添加引擎刚刚下载的 CodeQL 引擎的可执行文件</p>
<p><img src="https://img-blog.csdnimg.cn/img_convert/80218c8e03b9e69baef9e37553bf9faf.png" alt="image-20220304225259649"></p>
<p>就是codeql.zip 解压后对于系统的可执行文件地址<img src="https://img-blog.csdnimg.cn/img_convert/1b663484abb11ad4a00eaf9e60d6cf86.png" alt="image-20220304225430633"></p>
<p> </p>
<h3 id="5-系统环境变量添加"><a href="#5-系统环境变量添加" class="headerlink" title="5 系统环境变量添加"></a>5 系统环境变量添加</h3><p> <br>为了方便后面使用codeql，还需要把刚刚那个添加到系统里面</p>
<p>我是Mac 就是这样</p>
<figure class="highlight plaintext"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br></pre></td><td class="code"><pre><span class="line">vim ~/.zshrc</span><br><span class="line">alias codeql=&quot;/Users/zy/Documents/project/codeql/CodeQLCLI/codeql&quot;</span><br></pre></td></tr></table></figure>

<p>windows 就和添加Java环境变量一样，设置一个path到刚刚到codeql.exe 那个目录就行了</p>
<p>到这里环境应该就是好了，下一步就是建立数据库了（或导入数据库）</p>
<p>    
 </p>
<h2 id="0x03-创建数据库（Java）"><a href="#0x03-创建数据库（Java）" class="headerlink" title="0x03 创建数据库（Java）"></a>0x03 创建数据库（Java）</h2><p> </p>
<ul>
<li>打开终端使用 codeql命令</li>
</ul>
<figure class="highlight plaintext"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">codeql database create [数据库存的路径]  --language=&quot;java&quot;  --command=&quot;mvn clean install --file pom.xml&quot; --source-root=[源码路径路径]</span><br></pre></td></tr></table></figure>

<p>例如我的用的这个项目作为审计的目标 <a target="_blank" rel="noopener" href="https://github.com/godzeo/java-sec-code">https://github.com/godzeo/java-sec-code</a></p>
<figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">codeql database create /Users/zy/Documents/project/codeql/vscode-codeql-starter-main/database/codeql_java-sec-code  --language=&quot;java&quot;  --command=&quot;mvn clean install --file pom.xml&quot; --source-root=/Users/zy/Documents/project/sec_java_vul/java-sec-code</span><br></pre></td></tr></table></figure>

<p>然后把这个命令拆解看一下</p>
<table>
<thead>
<tr>
<th>codeql database create java-database</th>
<th>创建数据库，名字为codeql_java-sec-code</th>
</tr>
</thead>
<tbody><tr>
<td>-language&#x3D;java</td>
<td>编译语言为java</td>
</tr>
<tr>
<td>-command&#x3D;“mvn clean install –file pom.xml”</td>
<td>利用命令进行源码编译</td>
</tr>
<tr>
<td>–source-root</td>
<td>设置源码的路径</td>
</tr>
</tbody></table>
<p>成功建库</p>
<p><img src="https://img-blog.csdnimg.cn/img_convert/87b24445faaf162524b17454cefb235f.png" alt="image-20220305164718115"></p>
<p> </p>
<h2 id="0x04-导入库进行查询"><a href="#0x04-导入库进行查询" class="headerlink" title="0x04 导入库进行查询"></a>0x04 导入库进行查询</h2><p> </p>
<p>在vscode里面找到 导入数据库</p>
<p><img src="https://img-blog.csdnimg.cn/img_convert/0c7a8368eba51c627e4118781cda3bab.png" alt="image-20220305164846289"></p>
<p>这样就是导入成功了</p>
<p><img src="https://img-blog.csdnimg.cn/img_convert/738e5fe7a38bfc958543ddbe64af0c88.png" alt="image-20220305164933079"></p>
<p>下面开始查询：</p>
<figure class="highlight plaintext"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br></pre></td><td class="code"><pre><span class="line">跟目录/ql/java/ql/src/Security                 放着一些官方的规则(java)，可直接用。</span><br><span class="line">这跟目录/ql/java/ql/src/experimental/Security  一些还在实验中的规则(java)。</span><br></pre></td></tr></table></figure>

<p>找到规则文件试一下，xss.ql 文件 ，右键 Run Query</p>
<p><img src="https://img-blog.csdnimg.cn/img_convert/6d797139186e93960c732702e8e527e0.png" alt="image-20220305165221286"></p>
<p>出结果了，跑通了这就是</p>
<p><img src="https://img-blog.csdnimg.cn/img_convert/b4ac3fe75d4adfda68b9c3ebe8614e7a.png" alt="image-20220305165413207"></p>
<p>然后点一下就找到了漏洞点了。</p>
<p><img src="https://img-blog.csdnimg.cn/img_convert/23796c41f92e639d123a40bdbfbeaa4f.png" alt="image-20220305165516750"></p>
<p>基础的完成之后，这就能勉勉强强用了，然后就是学习语法规则，自己写规则使用了</p>
</article><div class="post-copyright"><div class="post-copyright__author"><span class="post-copyright-meta">文章作者: </span><span class="post-copyright-info"><a href="https://godzeo.github.io">Zeo</a></span></div><div class="post-copyright__type"><span class="post-copyright-meta">文章链接: </span><span class="post-copyright-info"><a href="https://godzeo.github.io/2022/03/14/Codeql%20%E7%8E%AF%E5%A2%83%E6%89%8B%E6%A8%A1%E6%89%8B%E6%90%AD%E5%BB%BA%E5%92%8C%E7%AE%80%E5%8D%95%E4%BD%BF%E7%94%A8/">https://godzeo.github.io/2022/03/14/Codeql%20%E7%8E%AF%E5%A2%83%E6%89%8B%E6%A8%A1%E6%89%8B%E6%90%AD%E5%BB%BA%E5%92%8C%E7%AE%80%E5%8D%95%E4%BD%BF%E7%94%A8/</a></span></div><div class="post-copyright__notice"><span class="post-copyright-meta">版权声明: </span><span class="post-copyright-info">本博客所有文章除特别声明外，均采用 <a href="https://creativecommons.org/licenses/by-nc-sa/4.0/" target="_blank">CC BY-NC-SA 4.0</a> 许可协议。转载请注明来自 <a href="https://godzeo.github.io" target="_blank">Zeo's Security Lab</a>！</span></div></div><div class="tag_share"><div class="post-meta__tag-list"><a class="post-meta__tags" href="/tags/vscode-web%E5%AE%89%E5%85%A8-%E4%BB%A3%E7%A0%81%E5%AE%A1%E8%AE%A1-%E5%AE%89%E5%85%A8/">vscode web安全 代码审计 安全</a></div><div class="post_share"><div class="social-share" data-image="https://image-1257110520.cos.ap-beijing.myqcloud.com/old/202210231225559.webp" data-sites="facebook,twitter,wechat,weibo,qq"></div><link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/butterfly-extsrc/sharejs/dist/css/share.min.css" media="print" onload="this.media='all'"><script src="https://cdn.jsdelivr.net/npm/butterfly-extsrc/sharejs/dist/js/social-share.min.js" defer></script></div></div><nav class="pagination-post" id="pagination"><div class="prev-post pull-left"><a href="/2022/03/27/%E8%BD%AC%E8%BD%BD%EF%BC%9AGitee%20%E5%9B%BE%E5%BA%8A%20%E5%A4%96%E9%93%BE%E9%97%AE%E9%A2%98%20%E5%A4%84%E7%90%86/"><img class="prev-cover" src="https://image-1257110520.cos.ap-beijing.myqcloud.com/old/202210231225569.webp" onerror="onerror=null;src='/img/404.jpg'" alt="cover of previous post"><div class="pagination-info"><div class="label">上一篇</div><div class="prev_info">转载：Gitee 图床 外链问题 处理</div></div></a></div><div class="next-post pull-right"><a href="/2022/03/12/Java%E9%A2%84%E7%BC%96%E8%AF%91%E4%B8%80%E4%BA%9B%E5%9C%BA%E6%99%AF%E4%B8%8B%E7%9A%84%E5%B1%80%E9%99%90.md/"><img class="next-cover" src="https://image-1257110520.cos.ap-beijing.myqcloud.com/old/202210231225559.webp" onerror="onerror=null;src='/img/404.jpg'" alt="cover of next post"><div class="pagination-info"><div class="label">下一篇</div><div class="next_info">Java预编译一些场景下的局限.md</div></div></a></div></nav></div><div class="aside-content" id="aside-content"><div class="card-widget card-info"><div class="is-center"><div class="avatar-img"><img src="https://image-1257110520.cos.ap-beijing.myqcloud.com/old/202210231013354.png" onerror="this.onerror=null;this.src='/img/friend_404.gif'" alt="avatar"/></div><div class="author-info__name">Zeo</div><div class="author-info__description">专注于安全,分享生活,分享知识</div></div><div class="card-info-data site-data is-center"><a href="/archives/"><div class="headline">文章</div><div class="length-num">125</div></a><a href="/tags/"><div class="headline">标签</div><div class="length-num">46</div></a><a href="/categories/"><div class="headline">分类</div><div class="length-num">9</div></a></div><a id="card-info-btn" target="_blank" rel="noopener" href="https://github.com/godzeo"><i class="fab fa-github"></i><span>Follow Me</span></a><div class="card-info-social-icons is-center"><a class="social-icon" href="https://github.com/godzeo" target="_blank" title="Github"><i class="fab fa-github"></i></a><a class="social-icon" href="mailto:zzzhhhaaaiiii@gmail.com" target="_blank" title="Email"><i class="fas fa-envelope"></i></a></div></div><div class="card-widget card-announcement"><div class="item-headline"><i class="fas fa-bullhorn fa-shake"></i><span>公告</span></div><div class="announcement_content">Weclome my blog</div></div><div class="sticky_layout"><div class="card-widget" id="card-toc"><div class="item-headline"><i class="fas fa-stream"></i><span>目录</span><span class="toc-percentage"></span></div><div class="toc-content"><ol class="toc"><li class="toc-item toc-level-2"><a class="toc-link" href="#0x00-%E5%89%8D%E8%A8%80"><span class="toc-number">1.</span> <span class="toc-text">0x00 前言</span></a></li><li class="toc-item toc-level-2"><a class="toc-link" href="#0x01-CodeQL%E6%98%AF%E4%BB%80%E4%B9%88"><span class="toc-number">2.</span> <span class="toc-text">0x01 CodeQL是什么</span></a></li><li class="toc-item toc-level-2"><a class="toc-link" href="#0x01-%E7%9B%B8%E5%85%B3%E4%B8%8B%E8%BD%BD"><span class="toc-number">3.</span> <span class="toc-text">0x01 相关下载</span></a></li><li class="toc-item toc-level-2"><a class="toc-link" href="#0x02-%E5%AE%89%E8%A3%85%E8%AF%A6%E7%BB%86%E6%AD%A5%E9%AA%A4"><span class="toc-number">4.</span> <span class="toc-text">0x02 安装详细步骤</span></a><ol class="toc-child"><li class="toc-item toc-level-3"><a class="toc-link" href="#1%E3%80%81vscode-%E7%8E%AF%E5%A2%83"><span class="toc-number">4.1.</span> <span class="toc-text">1、vscode 环境</span></a></li><li class="toc-item toc-level-3"><a class="toc-link" href="#2-%E5%AE%89%E8%A3%85-CodeQL-%E5%BC%95%E6%93%8E"><span class="toc-number">4.2.</span> <span class="toc-text">2 安装 CodeQL 引擎</span></a></li><li class="toc-item toc-level-3"><a class="toc-link" href="#3-%E5%85%8B%E9%9A%86%E5%B7%A5%E4%BD%9C%E8%BD%A6%E9%97%B4-Codeql-starter"><span class="toc-number">4.3.</span> <span class="toc-text">3 克隆工作车间 Codeql starter</span></a></li><li class="toc-item toc-level-3"><a class="toc-link" href="#4-%E9%85%8D%E7%BD%AE%E7%8E%AF%E5%A2%83%E5%8F%98%E9%87%8F"><span class="toc-number">4.4.</span> <span class="toc-text">4 配置环境变量</span></a></li><li class="toc-item toc-level-3"><a class="toc-link" href="#5-%E7%B3%BB%E7%BB%9F%E7%8E%AF%E5%A2%83%E5%8F%98%E9%87%8F%E6%B7%BB%E5%8A%A0"><span class="toc-number">4.5.</span> <span class="toc-text">5 系统环境变量添加</span></a></li></ol></li><li class="toc-item toc-level-2"><a class="toc-link" href="#0x03-%E5%88%9B%E5%BB%BA%E6%95%B0%E6%8D%AE%E5%BA%93%EF%BC%88Java%EF%BC%89"><span class="toc-number">5.</span> <span class="toc-text">0x03 创建数据库（Java）</span></a></li><li class="toc-item toc-level-2"><a class="toc-link" href="#0x04-%E5%AF%BC%E5%85%A5%E5%BA%93%E8%BF%9B%E8%A1%8C%E6%9F%A5%E8%AF%A2"><span class="toc-number">6.</span> <span class="toc-text">0x04 导入库进行查询</span></a></li></ol></div></div><div class="card-widget card-recent-post"><div class="item-headline"><i class="fas fa-history"></i><span>最新文章</span></div><div class="aside-list"><div class="aside-list-item"><a class="thumbnail" href="/2022/11/28/Nosql%20inject%E6%B3%A8%E5%85%A5/" title="Nosql inject注入"><img src="https://image-1257110520.cos.ap-beijing.myqcloud.com/old/202210231217732.webp" onerror="this.onerror=null;this.src='/img/404.jpg'" alt="Nosql inject注入"/></a><div class="content"><a class="title" href="/2022/11/28/Nosql%20inject%E6%B3%A8%E5%85%A5/" title="Nosql inject注入">Nosql inject注入</a><time datetime="2022-11-28T07:28:02.000Z" title="发表于 2022-11-28 15:28:02">2022-11-28</time></div></div><div class="aside-list-item"><a class="thumbnail" href="/2022/11/15/%E4%BC%81%E4%B8%9A%20SDLC%20%E5%AE%89%E5%85%A8%E7%94%9F%E5%91%BD%E5%91%A8%E6%9C%9F%E7%AE%A1%E7%90%86/" title="企业 SDLC 安全生命周期管理"><img src="https://image-1257110520.cos.ap-beijing.myqcloud.com/old/202210231217732.webp" onerror="this.onerror=null;this.src='/img/404.jpg'" alt="企业 SDLC 安全生命周期管理"/></a><div class="content"><a class="title" href="/2022/11/15/%E4%BC%81%E4%B8%9A%20SDLC%20%E5%AE%89%E5%85%A8%E7%94%9F%E5%91%BD%E5%91%A8%E6%9C%9F%E7%AE%A1%E7%90%86/" title="企业 SDLC 安全生命周期管理">企业 SDLC 安全生命周期管理</a><time datetime="2022-11-15T14:03:44.000Z" title="发表于 2022-11-15 22:03:44">2022-11-15</time></div></div><div class="aside-list-item"><a class="thumbnail" href="/2022/11/05/Go%20%E4%BB%A3%E7%A0%81%E5%AE%A1%E8%AE%A1%E6%BC%8F%E6%B4%9E(File%20Operation!Redirect!Cors)/" title="Go 代码审计漏洞(File Operation\Redirect\Cors)"><img src="https://image-1257110520.cos.ap-beijing.myqcloud.com/old/202210231225566.webp" onerror="this.onerror=null;this.src='/img/404.jpg'" alt="Go 代码审计漏洞(File Operation\Redirect\Cors)"/></a><div class="content"><a class="title" href="/2022/11/05/Go%20%E4%BB%A3%E7%A0%81%E5%AE%A1%E8%AE%A1%E6%BC%8F%E6%B4%9E(File%20Operation!Redirect!Cors)/" title="Go 代码审计漏洞(File Operation\Redirect\Cors)">Go 代码审计漏洞(File Operation\Redirect\Cors)</a><time datetime="2022-11-05T09:15:28.000Z" title="发表于 2022-11-05 17:15:28">2022-11-05</time></div></div><div class="aside-list-item"><a class="thumbnail" href="/2022/10/30/Go%20%E4%BB%A3%E7%A0%81%E5%AE%A1%E8%AE%A1%E9%AB%98%E5%8D%B1%E6%BC%8F%E6%B4%9E(sqli!cmd!ssrf)/" title="Go 代码审计高危漏洞(sqli\cmd\ssrf)"><img src="https://image-1257110520.cos.ap-beijing.myqcloud.com/old/202210231225566.webp" onerror="this.onerror=null;this.src='/img/404.jpg'" alt="Go 代码审计高危漏洞(sqli\cmd\ssrf)"/></a><div class="content"><a class="title" href="/2022/10/30/Go%20%E4%BB%A3%E7%A0%81%E5%AE%A1%E8%AE%A1%E9%AB%98%E5%8D%B1%E6%BC%8F%E6%B4%9E(sqli!cmd!ssrf)/" title="Go 代码审计高危漏洞(sqli\cmd\ssrf)">Go 代码审计高危漏洞(sqli\cmd\ssrf)</a><time datetime="2022-10-30T06:57:14.000Z" title="发表于 2022-10-30 14:57:14">2022-10-30</time></div></div><div class="aside-list-item"><a class="thumbnail" href="/2022/05/10/Java%E4%BB%A3%E7%A0%81%E5%AE%A1%E8%AE%A1%EF%BC%9A%20ClassLoader%E5%BA%94%E7%94%A8/" title="Java代码审计： ClassLoader应用"><img src="https://image-1257110520.cos.ap-beijing.myqcloud.com/old/202210231225566.webp" onerror="this.onerror=null;this.src='/img/404.jpg'" alt="Java代码审计： ClassLoader应用"/></a><div class="content"><a class="title" href="/2022/05/10/Java%E4%BB%A3%E7%A0%81%E5%AE%A1%E8%AE%A1%EF%BC%9A%20ClassLoader%E5%BA%94%E7%94%A8/" title="Java代码审计： ClassLoader应用">Java代码审计： ClassLoader应用</a><time datetime="2022-05-10T08:21:21.000Z" title="发表于 2022-05-10 16:21:21">2022-05-10</time></div></div></div></div></div></div></main><footer id="footer"><div id="footer-wrap"><div class="copyright">&copy;2019 - 2022 By Zeo</div><div class="footer_custom_text">Hi, welcome to my blog!</div></div></footer></div><div id="rightside"><div id="rightside-config-hide"><button id="readmode" type="button" title="阅读模式"><i class="fas fa-book-open"></i></button><button id="darkmode" type="button" title="浅色和深色模式转换"><i class="fas fa-adjust"></i></button><button id="hide-aside-btn" type="button" title="单栏和双栏切换"><i class="fas fa-arrows-alt-h"></i></button></div><div id="rightside-config-show"><button id="rightside_config" type="button" title="设置"><i class="fas fa-cog fa-spin"></i></button><button class="close" id="mobile-toc-button" type="button" title="目录"><i class="fas fa-list-ul"></i></button><button id="go-up" type="button" title="回到顶部"><i class="fas fa-arrow-up"></i></button></div></div><div><script src="/js/utils.js"></script><script src="/js/main.js"></script><script src="https://cdn.jsdelivr.net/npm/@fancyapps/ui/dist/fancybox.umd.min.js"></script><div class="js-pjax"></div></div></body></html>